package com.zbkj.admin.config;

import com.zbkj.admin.interceptor.DynamicDatasourceInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * token验证拦截器
 * +----------------------------------------------------------------------
 * | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 * +----------------------------------------------------------------------
 * | Author: CRMEB Team <admin@crmeb.com>
 * +----------------------------------------------------------------------
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

//    @Bean
//    public FilterRegistrationBean<ImageCompressionFilter> imageFilter() {
//        FilterRegistrationBean<ImageCompressionFilter> bean = new FilterRegistrationBean<>();
//        bean.setFilter(new ImageCompressionFilter());
//        bean.addUrlPatterns("/*");
//        return bean;
//    }

    /**
     * 添加自定义拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加token拦截器.
        //addPathPatterns添加需要拦截的命名空间；
        //excludePathPatterns添加排除拦截命名空间
        registry.addInterceptor(new DynamicDatasourceInterceptor()).addPathPatterns("/**");
//        registry.addInterceptor(new ImagesReduceInterceptor()).addPathPatterns("/**");
    }
}
